﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToVis.CApExportToVisCadIdGenerator
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ExportToVis;

public class CApExportToVisCadIdGenerator
{
  private string prefix = "CHLD0000\\0";
  private string separator_ = ";0;0:\\0";
  private ITxObject m_exportedObject;
  private string plmxmlFileExtension = ".asm";

  public CApExportToVisCadIdGenerator(string objectId, string fileNamePrefix)
  {
    this.m_exportedObject = TxApplication.ActiveDocument.GetObjectById(objectId);
    this.prefix = this.prefix + fileNamePrefix + this.plmxmlFileExtension + this.separator_;
  }

  public string ComputeCADIDOfJtNode()
  {
    string current_id = "";
    this.ComputeCADIDOfJtNodeTraverse(ref current_id, this.m_exportedObject);
    return this.prefix + current_id;
  }

  private void ComputeCADIDOfJtNodeTraverse(ref string current_id, ITxObject obj)
  {
    string name = obj.Name;
    if (name.Length > 0)
    {
      string str1 = name;
      string str2 = (!TxEngineeringDataInternal.IsEntity(obj) ? str1 + ".asm" : str1 + ".part") + this.separator_;
      current_id = str2 + current_id;
    }
    ITxObject collection = (ITxObject) obj.Collection;
    if (collection == TxApplication.ActiveDocument.PhysicalRoot)
      return;
    this.ComputeCADIDOfJtNodeTraverse(ref current_id, collection);
  }

  public string GenerateCadIdFromObjectId() => this.ComputeCADIDOfJtNode();
}
